package hhh.zjh.com.weightgauge;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;

public class Weight extends AppCompatActivity {
      String sex="";
      float height;

     Button star;
     EditText ediheigth;
     RadioGroup Rsex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        this.star = (Button)findViewById(R.id.start_button);
        this.ediheigth = (EditText) findViewById(R.id.hight_input);
        this.Rsex=(RadioGroup)findViewById(R.id.radioGroup);
        Rsex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.male) {
                    sex = "M";
                } else {
                    sex = "F";
                }
            }
        });
        star.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent turn = new Intent(Weight.this, Result.class);
                height = Float.parseFloat(ediheigth.getText().toString());
                turn.putExtra("height",height);
                turn.putExtra("sex",sex);
                startActivity(turn);
            }
        });


    }
}
